package org.jeecg.modules.online.cgform.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.lang.invoke.SerializedLambda;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.online.auth.p004b.AuthConstants;
import org.jeecg.modules.online.auth.service.IOnlAuthPageService;
import org.jeecg.modules.online.cgform.consts.ExtendJsonKey;
import org.jeecg.modules.online.cgform.consts.OnlineConst;
import org.jeecg.modules.online.cgform.entity.OnlCgformButton;
import org.jeecg.modules.online.cgform.entity.OnlCgformEnhanceJs;
import org.jeecg.modules.online.cgform.entity.OnlCgformField;
import org.jeecg.modules.online.cgform.entity.OnlCgformHead;
import org.jeecg.modules.online.cgform.model.HrefSlots;
import org.jeecg.modules.online.cgform.model.OnlColumn;
import org.jeecg.modules.online.cgform.model.OnlComplexModel;
import org.jeecg.modules.online.cgform.model.OnlForeignKey;
import org.jeecg.modules.online.cgform.model.ScopedSlots;
import org.jeecg.modules.online.cgform.model.TreeSelectColumn;
import org.jeecg.modules.online.cgform.p007a.LinkDown;
import org.jeecg.modules.online.cgform.service.IOnlCgformFieldService;
import org.jeecg.modules.online.cgform.service.IOnlCgformHeadService;
import org.jeecg.modules.online.cgform.service.IOnlineService;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.cgform.utils.EnhanceJsUtil;
import org.jeecg.modules.online.cgform.utils.OnlFormShowType;
import org.jeecg.modules.online.cgform.utils.OnlSlotRender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

@Service("onlineService")
/* renamed from: org.jeecg.modules.online.cgform.service.a.j */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/cgform/service/a/j.class */
public class OnlineServiceImpl implements IOnlineService {

    /* renamed from: a */
    private static final Logger f463a = LoggerFactory.getLogger(OnlineServiceImpl.class);
    @Autowired
    private IOnlCgformFieldService onlCgformFieldService;
    @Autowired
    private IOnlCgformHeadService onlCgformHeadService;
    @Autowired
    @Lazy
    private ISysBaseAPI sysBaseAPI;
    @Autowired
    private IOnlAuthPageService onlAuthPageService;

    /* renamed from: a */
//    private static /* synthetic */ Object m150a(SerializedLambda serializedLambda) {
//        String implMethodName = serializedLambda.getImplMethodName();
//        boolean z = true;
//        switch (implMethodName.hashCode()) {
//            case -1998322493:
//                if (implMethodName.equals("getTableName")) {
//                    z = true;
//                    break;
//                }
//                break;
//            case -1430087557:
//                if (implMethodName.equals("getIsShowList")) {
//                    z = true;
//                    break;
//                }
//                break;
//            case -1279489738:
//                if (implMethodName.equals("getDbIsPersist")) {
//                    z = true;
//                    break;
//                }
//                break;
//            case -1188757112:
//                if (implMethodName.equals("getIsQuery")) {
//                    z = true;
//                    break;
//                }
//                break;
//            case -982778162:
//                if (implMethodName.equals("getOrderNum")) {
//                    z = true;
//                    break;
//                }
//                break;
//            case 713008857:
//                if (implMethodName.equals("getCgformHeadId")) {
//                    z = true;
//                    break;
//                }
//                break;
//            case 1243744913:
//                if (implMethodName.equals("getDbFieldName")) {
//                    z = false;
//                    break;
//                }
//                break;
//        }
//        switch (z) {
//            case false:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getDbFieldName();
//                    };
//                }
//                break;
//            case true:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//                    return (v0) -> {
//                        return v0.getOrderNum();
//                    };
//                }
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//                    return (v0) -> {
//                        return v0.getOrderNum();
//                    };
//                }
//                break;
//            case true:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getCgformHeadId();
//                    };
//                }
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getCgformHeadId();
//                    };
//                }
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getCgformHeadId();
//                    };
//                }
//                break;
//            case true:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformHead") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getTableName();
//                    };
//                }
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformHead") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getTableName();
//                    };
//                }
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformHead") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getTableName();
//                    };
//                }
//                break;
//            case AuthConstants.f111o /* 4 */:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//                    return (v0) -> {
//                        return v0.getIsShowList();
//                    };
//                }
//                break;
//            case true:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//                    return (v0) -> {
//                        return v0.getDbIsPersist();
//                    };
//                }
//                break;
//            case true:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/cgform/entity/OnlCgformField") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//                    return (v0) -> {
//                        return v0.getIsQuery();
//                    };
//                }
//                break;
//        }
//        throw new IllegalArgumentException("Invalid lambda deserialization");
//    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    public OnlComplexModel queryOnlineConfig(OnlCgformHead head, String username) {
        String id = head.getId();
        boolean m349a = CgformUtil.m349a(head);
        List<OnlCgformField> m143b = m143b(id);
        List<String> queryHideCode = this.onlAuthPageService.queryHideCode(id, true);
        ArrayList arrayList = new ArrayList();
        HashMap hashMap = new HashMap(5);
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = new ArrayList();
        ArrayList arrayList4 = new ArrayList();
        Map<String,Integer> hashMap2 = new HashMap(5);
        List<String> selectFieldList = head.getSelectFieldList();
        for (OnlCgformField onlCgformField : m143b) {
            String dbFieldName = onlCgformField.getDbFieldName();
            String mainTable = onlCgformField.getMainTable();
            String mainField = onlCgformField.getMainField();
            if (oConvertUtils.isNotEmpty(mainField) && oConvertUtils.isNotEmpty(mainTable)) {
                arrayList3.add(new OnlForeignKey(dbFieldName, mainField));
            }
            if (onlCgformField.getIsShowList() != null && 1 == onlCgformField.getIsShowList().intValue() && !"id".equals(dbFieldName) && !queryHideCode.contains(dbFieldName) && !arrayList4.contains(dbFieldName) && (selectFieldList == null || selectFieldList.size() <= 0 || selectFieldList.indexOf(dbFieldName) >= 0)) {
                OnlColumn m146a = m146a(onlCgformField, hashMap, arrayList2);
                hashMap2.put(onlCgformField.getDbFieldName(), 1);
                arrayList.add(m146a);
                String linkField = m146a.getLinkField();
                if (linkField != null && !"".equals(linkField)) {
                    m148a(m143b, arrayList4, arrayList, dbFieldName, linkField);
                }
            }
        }
        m149a(arrayList, arrayList4);
        if (m349a) {
            List<OnlColumn> m144a = m144a(head, hashMap, arrayList2, hashMap2);
            if (m144a.size() > 0) {
                ArrayList arrayList5 = new ArrayList();
                for (String str : hashMap2.keySet()) {
                    if (hashMap2.get(str).intValue() > 1) {
                        arrayList5.add(str);
                    }
                }
                for (OnlColumn onlColumn : m144a) {
                    String dataIndex = onlColumn.getDataIndex();
                    if (arrayList5.contains(dataIndex)) {
                        onlColumn.setDataIndex(CgformUtil.m308l(onlColumn.getTableName()) + "_" + dataIndex);
                    }
                    arrayList.add(onlColumn);
                }
            }
        }
        OnlComplexModel onlComplexModel = new OnlComplexModel();
        onlComplexModel.setCode(id);
        onlComplexModel.setTableType(head.getTableType());
        onlComplexModel.setFormTemplate(head.getFormTemplate());
        onlComplexModel.setDescription(head.getTableTxt());
        onlComplexModel.setCurrentTableName(head.getTableName());
        onlComplexModel.setPaginationFlag(head.getIsPage());
        onlComplexModel.setCheckboxFlag(head.getIsCheckbox());
        onlComplexModel.setScrollFlag(head.getScroll());
        onlComplexModel.setRelationType(head.getRelationType());
        onlComplexModel.setColumns(arrayList);
        onlComplexModel.setDictOptions(hashMap);
        onlComplexModel.setFieldHrefSlots(arrayList2);
        onlComplexModel.setForeignKeys(arrayList3);
        onlComplexModel.setHideColumns(queryHideCode);
        List<OnlCgformButton> queryButtonList = this.onlCgformHeadService.queryButtonList(id, true);
        ArrayList arrayList6 = new ArrayList();
        for (OnlCgformButton onlCgformButton : queryButtonList) {
            if (!queryHideCode.contains(onlCgformButton.getButtonCode())) {
                arrayList6.add(onlCgformButton);
            }
        }
        onlComplexModel.setCgButtonList(arrayList6);
        OnlCgformEnhanceJs queryEnhanceJs = this.onlCgformHeadService.queryEnhanceJs(id, CgformUtil.f272ar);
        if (queryEnhanceJs != null && oConvertUtils.isNotEmpty(queryEnhanceJs.getCgJs())) {
            onlComplexModel.setEnhanceJs(EnhanceJsUtil.m297b(queryEnhanceJs.getCgJs(), queryButtonList));
        }
        if ("Y".equals(head.getIsTree())) {
            onlComplexModel.setPidField(head.getTreeParentIdField());
            onlComplexModel.setHasChildrenField(head.getTreeIdField());
            onlComplexModel.setTextField(head.getTreeFieldname());
        }
        return onlComplexModel;
    }

    /* renamed from: a */
    private void m149a(List<OnlColumn> list, List<String> list2) {
        Iterator<OnlColumn> it = list.iterator();
        while (it.hasNext()) {
            OnlColumn next = it.next();
            String dataIndex = next.getDataIndex();
            if (list2 != null && list2.indexOf(dataIndex) >= 0 && oConvertUtils.isEmpty(next.getCustomRender())) {
                it.remove();
            }
        }
    }

    /* renamed from: a */
    private String[] m152a(String str) {
        String[] strArr = {"", ""};
        if (str != null && !"".equals(str)) {
            JSONObject parseObject = JSON.parseObject(str);
            if (parseObject.containsKey(ExtendJsonKey.f131d)) {
                strArr[0] = oConvertUtils.camelToUnderline(parseObject.getString(ExtendJsonKey.f131d));
            }
            if (parseObject.containsKey(ExtendJsonKey.f133f)) {
                strArr[1] = oConvertUtils.camelToUnderline(parseObject.getString(ExtendJsonKey.f133f));
            }
        }
        return strArr;
    }

    /* renamed from: a */
    private void m148a(List<OnlCgformField> list, List<String> list2, List<OnlColumn> list3, String str, String str2) {
        String[] split;
        if (oConvertUtils.isNotEmpty(str2)) {
            for (String str3 : str2.split(CgformUtil.f233E)) {
                Iterator<OnlCgformField> it = list.iterator();
                while (true) {
                    if (it.hasNext()) {
                        OnlCgformField next = it.next();
                        String dbFieldName = next.getDbFieldName();
                        if (1 == next.getIsShowList().intValue() && str3.equals(dbFieldName)) {
                            list2.add(str3);
                            OnlColumn onlColumn = new OnlColumn(next.getDbFieldTxt(), dbFieldName);
                            onlColumn.setCustomRender(str);
                            list3.add(onlColumn);
                            break;
                        }
                    }
                }
            }
        }
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    public JSONObject queryOnlineFormObj(OnlCgformHead head, OnlCgformEnhanceJs onlCgformEnhanceJs) {
        JSONObject jSONObject = new JSONObject();
        String id = head.getId();
        String taskId = head.getTaskId();
        List<OnlCgformField> queryAvailableFields = this.onlCgformFieldService.queryAvailableFields(id, head.getTableName(), taskId, false);
        ArrayList arrayList = new ArrayList();
        if (oConvertUtils.isEmpty(taskId)) {
            List<String> queryFormDisabledCode = this.onlAuthPageService.queryFormDisabledCode(head.getId());
            if (queryFormDisabledCode != null && queryFormDisabledCode.size() > 0 && queryFormDisabledCode.get(0) != null) {
                arrayList.addAll(queryFormDisabledCode);
            }
        } else {
            List<String> queryDisabledFields = this.onlCgformFieldService.queryDisabledFields(head.getTableName(), taskId);
            if (queryDisabledFields != null && queryDisabledFields.size() > 0 && queryDisabledFields.get(0) != null) {
                arrayList.addAll(queryDisabledFields);
            }
        }
        EnhanceJsUtil.m301a(onlCgformEnhanceJs, head.getTableName(), queryAvailableFields);
        TreeSelectColumn treeSelectColumn = null;
        if ("Y".equals(head.getIsTree())) {
            treeSelectColumn = new TreeSelectColumn();
            treeSelectColumn.setCodeField("id");
            treeSelectColumn.setFieldName(head.getTreeParentIdField());
            treeSelectColumn.setPidField(head.getTreeParentIdField());
            treeSelectColumn.setPidValue(CgformUtil.f304aX);
            treeSelectColumn.setHsaChildField(head.getTreeIdField());
            treeSelectColumn.setTableName(CgformUtil.m317f(head.getTableName()));
            treeSelectColumn.setTextField(head.getTreeFieldname());
        }
        JSONObject m362a = CgformUtil.m362a(queryAvailableFields, arrayList, treeSelectColumn);
        m362a.put(CgformUtil.f300aT, head.getTableName());
        m362a.put("describe", head.getTableTxt());
        jSONObject.put("schema", m362a);
        jSONObject.put("head", head);
        List<OnlCgformButton> queryFormValidButton = queryFormValidButton(id);
        if (queryFormValidButton != null && queryFormValidButton.size() > 0) {
            jSONObject.put("cgButtonList", queryFormValidButton);
        }
        if (onlCgformEnhanceJs != null && oConvertUtils.isNotEmpty(onlCgformEnhanceJs.getCgJs())) {
            onlCgformEnhanceJs.setCgJs(EnhanceJsUtil.m294c(onlCgformEnhanceJs.getCgJs(), queryFormValidButton));
            jSONObject.put("enhanceJs", EnhanceJsUtil.m305a(onlCgformEnhanceJs.getCgJs()));
        }
        return jSONObject;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    @Cacheable(value = {"sys:cache:online:form"}, key = "'erp'+ #head.id+'-'+#username")
    public JSONObject queryOnlineFormObj(OnlCgformHead head, String username) {
        return queryOnlineFormObj(head, this.onlCgformHeadService.queryEnhanceJs(head.getId(), CgformUtil.f271aq));
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    public List<OnlCgformButton> queryFormValidButton(String headId) {
        List<OnlCgformButton> queryButtonList = this.onlCgformHeadService.queryButtonList(headId, false);
        List<OnlCgformButton> list = null;
        if (queryButtonList != null && queryButtonList.size() > 0) {
            List<String> queryFormHideButton = this.onlAuthPageService.queryFormHideButton(((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId(), headId);
            list = (List) queryButtonList.stream().filter(onlCgformButton -> {
                return queryFormHideButton == null || queryFormHideButton.indexOf(onlCgformButton.getButtonCode()) < 0;
            }).collect(Collectors.toList());
        }
        return list;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    @Cacheable(value = {"sys:cache:online:form"}, key = "#head.id+'-'+#username")
    public JSONObject queryOnlineFormItem(OnlCgformHead head, String username) {
        head.setTaskId(null);
        return m145a(head);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    public JSONObject queryFlowOnlineFormItem(OnlCgformHead head, String username, String taskId) {
        head.setTaskId(taskId);
        return m145a(head);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    @Cacheable(value = {"sys:cache:online:form"}, key = "'enhancejs' + #code + '-' + #type")
    public String queryEnahcneJsString(String code, String type) {
        String str = "";
        OnlCgformEnhanceJs queryEnhanceJs = this.onlCgformHeadService.queryEnhanceJs(code, type);
        if (queryEnhanceJs != null && oConvertUtils.isNotEmpty(queryEnhanceJs.getCgJs())) {
            str = EnhanceJsUtil.m297b(queryEnhanceJs.getCgJs(), (List<OnlCgformButton>) null);
        }
        return str;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    public JSONObject getOnlineVue3QueryInfo(String headId) {
        String subTableStr;
        String[] split;
        OnlCgformHead onlCgformHead = (OnlCgformHead) this.onlCgformHeadService.getById(headId);
        if (onlCgformHead == null) {
            return null;
        }
        boolean m349a = CgformUtil.m349a(onlCgformHead);
        ArrayList arrayList = new ArrayList();
        JSONObject m151a = m151a(headId, (List<String>) arrayList, true, (String) null);
        JSONObject jSONObject = m151a.getJSONObject(CgformUtil.properties);
        m151a.put(CgformUtil.f298aR, onlCgformHead.getTableTxt());
        m151a.put(CgformUtil.f300aT, onlCgformHead.getTableName());
        m151a.put(CgformUtil.joinQuery, Boolean.valueOf(m349a));
        m151a.put(CgformUtil.f301aU, arrayList);
        if (oConvertUtils.isNotEmpty(onlCgformHead.getExtConfigJson())) {
            m151a.put(CgformUtil.f303aW, onlCgformHead.getExtConfigJson());
        }
        if (CgformUtil.f288aH.equals(onlCgformHead.getTableType()) && (subTableStr = onlCgformHead.getSubTableStr()) != null && !"".equals(subTableStr)) {
            for (String str : subTableStr.split(CgformUtil.f233E)) {
                OnlCgformHead onlCgformHead2 = this.onlCgformHeadService.getOne(new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getTableName, str));
                if (onlCgformHead2 != null) {
                    JSONObject m151a2 = m151a(onlCgformHead2.getId(), (List<String>) arrayList, false, str);
                    m151a2.put(CgformUtil.f298aR, onlCgformHead2.getTableTxt());
                    m151a2.put(CgformUtil.view, CgformUtil.f300aT);
                    jSONObject.put(str, m151a2);
                }
            }
        }
        return m151a;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlineService
    public List<DictModel> getOnlineTableDictData(String table, String text, String code) {
        List list = null;
        try {
            List list2 = this.onlCgformFieldService.list( (new LambdaQueryWrapper<OnlCgformField>().eq(OnlCgformField::getCgformHeadId, this.onlCgformHeadService.getTable(table).getId()))
            		.eq(OnlCgformField::getDbFieldName, text));
            if (list2 != null && list2.size() > 0) {
                OnlCgformField onlCgformField = (OnlCgformField) list2.get(0);
                String dictTable = onlCgformField.getDictTable();
                String dictField = onlCgformField.getDictField();
                String dictText = onlCgformField.getDictText();
                if (oConvertUtils.isNotEmpty(dictTable) && oConvertUtils.isNotEmpty(dictField) && oConvertUtils.isNotEmpty(dictText)) {
                    list = this.sysBaseAPI.queryTableDictItemsByCode(dictTable, dictText, dictField);
                } else if (oConvertUtils.isNotEmpty(dictField)) {
                    list = this.sysBaseAPI.queryDictItemsByCode(dictField);
                }
            }
        } catch (Exception e) {
            f463a.error("他表字段获取字典数据失败", e.getMessage());
        }
        List<DictModel> queryTableDictItemsByCode = this.sysBaseAPI.queryTableDictItemsByCode(table, text, code);
        if (list != null && list.size() > 0) {
            for (DictModel dictModel : queryTableDictItemsByCode) {
                String text2 = dictModel.getText();
                Iterator it = list.iterator();
                while (true) {
                    if (it.hasNext()) {
                        DictModel dictModel2 = (DictModel) it.next();
                        if (dictModel2.getValue().equals(text2)) {
                            dictModel.setText(dictModel2.getText());
                            break;
                        }
                    }
                }
            }
        }
        return queryTableDictItemsByCode;
    }

    /* renamed from: a */
    private JSONObject m151a(String str, List<String> list, boolean z, String str2) {
    	LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, str);        
        lambdaQueryWrapper.and(i -> i.and(j -> j.eq(OnlCgformField::getIsShowList, 1).or().eq(OnlCgformField::getIsQuery, 1)));
        
        lambdaQueryWrapper.eq(OnlCgformField::getDbIsPersist, OnlineConst.f140b);
        lambdaQueryWrapper.orderByAsc(OnlCgformField::getOrderNum);
        List<OnlCgformField> list2 = this.onlCgformFieldService.list(lambdaQueryWrapper);
        for (OnlCgformField onlCgformField : list2) {
            onlCgformField.setFieldDefaultValue(null);
            if ("1".equals(onlCgformField.getQueryConfigFlag())) {
                onlCgformField.setFieldDefaultValue(onlCgformField.getQueryDefVal());
                onlCgformField.setDictField(onlCgformField.getQueryDictField());
                onlCgformField.setDictTable(onlCgformField.getQueryDictTable());
                onlCgformField.setDictText(onlCgformField.getQueryDictText());
                onlCgformField.setFieldShowType(onlCgformField.getQueryShowType());
            }
            if (1 == onlCgformField.getIsQuery().intValue()) {
                if (z) {
                    list.add(onlCgformField.getDbFieldName());
                } else {
                    list.add(str2 + "@" + onlCgformField.getDbFieldName());
                }
            }
        }
        JSONObject m362a = CgformUtil.m362a(list2, (List<String>) null, (TreeSelectColumn) null);
        CgformUtil.m345b(m362a);
        return m362a;
    }

    /* renamed from: b */
    private List<OnlCgformField> m143b(String str) {
    	LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, str);
        lambdaQueryWrapper.orderByAsc(OnlCgformField::getOrderNum);
        return this.onlCgformFieldService.list(lambdaQueryWrapper);
    }

    /* renamed from: a */
    private JSONObject m145a(OnlCgformHead onlCgformHead) {
        List<String> queryFormDisabledCode;
        OnlCgformEnhanceJs queryEnhanceJs = this.onlCgformHeadService.queryEnhanceJs(onlCgformHead.getId(), CgformUtil.f271aq);
        JSONObject queryOnlineFormObj = queryOnlineFormObj(onlCgformHead, queryEnhanceJs);
        queryOnlineFormObj.put("formTemplate", onlCgformHead.getFormTemplate());
        List<String> queryHideCode = this.onlAuthPageService.queryHideCode(onlCgformHead.getId(), true);
        if (queryHideCode != null && queryHideCode.indexOf(AuthConstants.f112p) >= 0) {
            queryOnlineFormObj.put(AuthConstants.f113q, true);
        }
        if (onlCgformHead.getTableType().intValue() == 2) {
            JSONObject jSONObject = queryOnlineFormObj.getJSONObject("schema");
            String subTableStr = onlCgformHead.getSubTableStr();
            if (oConvertUtils.isNotEmpty(subTableStr)) {
                ArrayList<OnlCgformHead> arrayList = new ArrayList();
                for (String str : subTableStr.split(CgformUtil.f233E)) {
                    OnlCgformHead onlCgformHead2 = this.onlCgformHeadService.getOne(new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getTableName, str));
                    if (onlCgformHead2 != null) {
                        arrayList.add(onlCgformHead2);
                    }
                }
                if (arrayList.size() > 0) {
                    Collections.sort(arrayList, new Comparator<OnlCgformHead>() { // from class: org.jeecg.modules.online.cgform.service.a.j.1
                        @Override // java.util.Comparator
                        /* renamed from: a */
                        public int compare(OnlCgformHead onlCgformHead3, OnlCgformHead onlCgformHead4) {
                            Integer tabOrderNum = onlCgformHead3.getTabOrderNum();
                            if (tabOrderNum == null) {
                                tabOrderNum = 0;
                            }
                            Integer tabOrderNum2 = onlCgformHead4.getTabOrderNum();
                            if (tabOrderNum2 == null) {
                                tabOrderNum2 = 0;
                            }
                            return tabOrderNum.compareTo(tabOrderNum2);
                        }
                    });
                    for (OnlCgformHead onlCgformHead3 : arrayList) {
                        List<OnlCgformField> queryAvailableFields = this.onlCgformFieldService.queryAvailableFields(onlCgformHead3.getId(), onlCgformHead3.getTableName(), onlCgformHead.getTaskId(), false);
                        EnhanceJsUtil.m296b(queryEnhanceJs, onlCgformHead3.getTableName(), queryAvailableFields);
                        JSONObject jSONObject2 = new JSONObject();
                        new ArrayList();
                        if (oConvertUtils.isNotEmpty(onlCgformHead.getTaskId())) {
                            queryFormDisabledCode = this.onlCgformFieldService.queryDisabledFields(onlCgformHead3.getTableName(), onlCgformHead.getTaskId());
                        } else {
                            queryFormDisabledCode = this.onlAuthPageService.queryFormDisabledCode(onlCgformHead3.getId());
                        }
                        if (1 == onlCgformHead3.getRelationType().intValue()) {
                            jSONObject2 = CgformUtil.m362a(queryAvailableFields, queryFormDisabledCode, (TreeSelectColumn) null);
                        } else {
                            jSONObject2.put("columns", CgformUtil.m363a(queryAvailableFields, queryFormDisabledCode));
                            jSONObject2.put("hideButtons", this.onlAuthPageService.queryListHideButton(null, onlCgformHead3.getId()));
                        }
                        jSONObject2.put("foreignKey", this.onlCgformFieldService.queryForeignKey(onlCgformHead3.getId(), onlCgformHead.getTableName()));
                        jSONObject2.put("id", onlCgformHead3.getId());
                        jSONObject2.put("describe", onlCgformHead3.getTableTxt());
                        jSONObject2.put("key", onlCgformHead3.getTableName());
                        jSONObject2.put(CgformUtil.view, "tab");
                        jSONObject2.put("order", onlCgformHead3.getTabOrderNum());
                        jSONObject2.put("relationType", onlCgformHead3.getRelationType());
                        jSONObject2.put("formTemplate", onlCgformHead3.getFormTemplate());
                        jSONObject.getJSONObject(CgformUtil.properties).put(onlCgformHead3.getTableName(), jSONObject2);
                    }
                }
            }
            if (queryEnhanceJs != null && oConvertUtils.isNotEmpty(queryEnhanceJs.getCgJs())) {
                queryOnlineFormObj.put("enhanceJs", EnhanceJsUtil.m305a(queryEnhanceJs.getCgJs()));
            }
        }
        return queryOnlineFormObj;
    }

    /* renamed from: a */
    private OnlColumn m146a(OnlCgformField onlCgformField, Map<String, List<DictModel>> map, List<HrefSlots> list) {
        JSONObject parseObject;
        String dbFieldName = onlCgformField.getDbFieldName();
        OnlColumn onlColumn = new OnlColumn(onlCgformField.getDbFieldTxt(), dbFieldName);
        onlColumn.setDbType(onlCgformField.getDbType());
        String dictField = onlCgformField.getDictField();
        String fieldShowType = onlCgformField.getFieldShowType();
        if (fieldShowType == null) {
            return onlColumn;
        }
        if (oConvertUtils.isNotEmpty(dictField) && !CgformUtil.f241M.equals(fieldShowType) && !CgformUtil.f242N.equals(fieldShowType) && !CgformUtil.f263ai.equals(fieldShowType)) {
            List<DictModel> arrayList = new ArrayList();
            if (oConvertUtils.isNotEmpty(onlCgformField.getDictTable())) {
                arrayList = this.sysBaseAPI.queryTableDictItemsByCode(onlCgformField.getDictTable(), onlCgformField.getDictText(), dictField);
            } else if (oConvertUtils.isNotEmpty(onlCgformField.getDictField())) {
                arrayList = this.sysBaseAPI.queryDictItemsByCode(dictField);
            }
            map.put(dbFieldName, arrayList);
            onlColumn.setCustomRender(dbFieldName);
        }
        if (CgformUtil.f240L.equals(fieldShowType)) {
            map.put(dbFieldName, CgformUtil.m334b(onlCgformField));
            onlColumn.setCustomRender(dbFieldName);
        }
        if (CgformUtil.f242N.equals(fieldShowType)) {
            onlColumn.setFieldType(fieldShowType);
        }
        if (CgformUtil.f264aj.equals(fieldShowType)) {
            onlColumn.setFieldType(fieldShowType);
        }
        if (CgformUtil.f263ai.equals(fieldShowType)) {
            onlColumn.setFieldType(fieldShowType);
            onlColumn.setHrefSlotName(onlCgformField.getDictTable());
        }
        if (CgformUtil.f248T.equals(fieldShowType)) {
            LinkDown linkDown = (LinkDown) JSONObject.parseObject(onlCgformField.getDictTable(), LinkDown.class);
            try {
                map.put(dbFieldName, this.sysBaseAPI.queryTableDictItemsByCode(linkDown.getTable(), linkDown.getTxt(), linkDown.getKey()));
                onlColumn.setCustomRender(dbFieldName);
                onlColumn.setLinkField(linkDown.getLinkField());
            } catch (Exception e) {
                f463a.warn("联动组件配置错误!", e.getMessage());
            }
        }
        if (CgformUtil.f246R.equals(fieldShowType)) {
            String[] split = onlCgformField.getDictText().split(CgformUtil.f233E);
            map.put(dbFieldName, this.sysBaseAPI.queryTableDictItemsByCode(onlCgformField.getDictTable(), split[2], split[0]));
            onlColumn.setCustomRender(dbFieldName);
        }
        if (CgformUtil.f247S.equals(fieldShowType)) {
            String dictText = onlCgformField.getDictText();
            if (oConvertUtils.isEmpty(dictText)) {
                map.put(dbFieldName, this.sysBaseAPI.queryFilterTableDictInfo(CgformUtil.f256ab, CgformUtil.f257ac, "ID", CgformUtil.m320e(onlCgformField.getDictField())));
                onlColumn.setCustomRender(dbFieldName);
            } else {
                onlColumn.setCustomRender("_replace_text_" + dictText);
            }
        }
        if ("sel_depart".equals(fieldShowType)) {
            String[] m152a = m152a(onlCgformField.getFieldExtendJson());
            map.put(dbFieldName, this.sysBaseAPI.queryTableDictItemsByCode(CgformUtil.f253Y, m152a[1].length() > 0 ? m152a[1] : CgformUtil.f254Z, m152a[0].length() > 0 ? m152a[0] : "ID"));
            onlColumn.setCustomRender(dbFieldName);
        }
        if ("sel_user".equals(onlCgformField.getFieldShowType())) {
            String[] m152a2 = m152a(onlCgformField.getFieldExtendJson());
            map.put(dbFieldName, this.sysBaseAPI.queryTableDictItemsByCode(CgformUtil.f250V, m152a2[1].length() > 0 ? m152a2[1] : CgformUtil.f251W, m152a2[0].length() > 0 ? m152a2[0] : CgformUtil.f252X));
            onlColumn.setCustomRender(dbFieldName);
        }
        if (fieldShowType.indexOf("file") >= 0) {
            onlColumn.setScopedSlots(new ScopedSlots(OnlSlotRender.f322a));
        } else if (fieldShowType.indexOf("image") >= 0) {
            onlColumn.setScopedSlots(new ScopedSlots(OnlSlotRender.f323b));
        } else if (fieldShowType.indexOf(OnlFormShowType.f319c) >= 0) {
            onlColumn.setScopedSlots(new ScopedSlots(OnlSlotRender.f324c));
        } else if (fieldShowType.equals("date")) {
            onlColumn.setScopedSlots(new ScopedSlots(OnlSlotRender.f325d));
        } else if (fieldShowType.equals(OnlFormShowType.f321e)) {
            onlColumn.setScopedSlots(new ScopedSlots(OnlSlotRender.f327f));
        }
        if (StringUtils.isNotBlank(onlCgformField.getFieldHref())) {
            String str = OnlSlotRender.f326e + dbFieldName;
            onlColumn.setHrefSlotName(str);
            list.add(new HrefSlots(str, onlCgformField.getFieldHref()));
        }
        if ("1".equals(onlCgformField.getSortFlag())) {
            onlColumn.setSorter(true);
        }
        String fieldExtendJson = onlCgformField.getFieldExtendJson();
        if (oConvertUtils.isNotEmpty(fieldExtendJson)) {
            onlColumn.setFieldExtendJson(fieldExtendJson);
            if (fieldExtendJson.indexOf(ExtendJsonKey.f129b) > 0 && (parseObject = JSON.parseObject(fieldExtendJson)) != null && parseObject.get(ExtendJsonKey.f129b) != null) {
                onlColumn.setShowLength(oConvertUtils.getInt(parseObject.get(ExtendJsonKey.f129b)).intValue());
            }
        }
        return onlColumn;
    }

    /* renamed from: a */
    private List<OnlColumn> m144a(OnlCgformHead onlCgformHead, Map<String, List<DictModel>> map, List<HrefSlots> list, Map<String, Integer> map2) {
        String subTableStr;
        int intValue = onlCgformHead.getTableType().intValue();
        ArrayList arrayList = new ArrayList();
        if (intValue == 2 && (subTableStr = onlCgformHead.getSubTableStr()) != null && !"".equals(subTableStr)) {
            for (String str : subTableStr.split(CgformUtil.f233E)) {
                OnlCgformHead onlCgformHead2 = this.onlCgformHeadService.getOne(new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getTableName, str));
                if (onlCgformHead2 != null) {
                    List<String> queryHideCode = this.onlAuthPageService.queryHideCode(onlCgformHead2.getId(), true);
                    for (OnlCgformField onlCgformField : m143b(onlCgformHead2.getId())) {
                        if (1 == onlCgformField.getIsShowList().intValue() || 1 == onlCgformField.getIsQuery().intValue()) {
                            String dbFieldName = onlCgformField.getDbFieldName();
                            if (!queryHideCode.contains(dbFieldName) && !"id".equals(dbFieldName)) {
                                Integer num = map2.get(dbFieldName);
                                if (num == null) {
                                    map2.put(dbFieldName, 1);
                                } else {
                                    map2.put(dbFieldName, Integer.valueOf(num.intValue() + 1));
                                }
                                OnlColumn m146a = m146a(onlCgformField, map, list);
                                if (1 == onlCgformField.getIsShowList().intValue()) {
                                    m146a.setTableName(onlCgformHead2.getTableName());
                                    arrayList.add(m146a);
                                }
                            }
                        }
                    }
                }
            }
        }
        return arrayList;
    }
}
